/*
 * @Description: 数据预处理的node文件
 * @Author: Zhijian Qiao
 * @Date: 2020-02-05 02:56:27
 */
#include <ros/ros.h>
#include "glog/logging.h"
#include "tools/file_manager.hpp"
#include "global_defination/global_defination.h"
#include "data_pretreat/data_pretreat_flow.hpp"
#include "config.h"

using namespace avp_slam;

int main(int argc, char *argv[]) {

    ros::init(argc, argv, "data_pretreat_node");
    ros::NodeHandle nh("~");

    std::string cloud_topic;
    bool screen = false;
    nh.param<std::string>("cloud_topic", cloud_topic, "/synced_cloud");   // 给legoloam
    nh.param<bool>("screen", screen, "true");

    google::InitGoogleLogging(argv[0]);
    FLAGS_log_dir = WORK_SPACE_PATH + "/Log";
    FLAGS_alsologtostderr = screen;
    FLAGS_colorlogtostderr = true;
    FLAGS_log_prefix = true;
    FLAGS_logbufsecs = 0;
    FileManager::CreateDirectory(FLAGS_log_dir);

    LOG(INFO) << "data_pretreat_node/cloud_topic: " << cloud_topic;
    LOG(INFO) << "data_pretreat_node/screen: " << screen;

    Config::readConfig();

    std::shared_ptr<DataPretreatFlow> data_pretreat_flow_ptr = std::make_shared<DataPretreatFlow>(nh, cloud_topic);

    ros::Rate rate(200);
    while (ros::ok()) {
        ros::spinOnce();

        data_pretreat_flow_ptr->Run();

        rate.sleep();
    }

    return 0;
}